package com.meichis.yndms.model;

import android.text.TextUtils;

import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import java.io.Serializable;
import java.util.ArrayList;

@Entity
public class InspectTemplate implements Serializable {
    //二维键关联模式 1.字典表 2.产品表
    public int Dim2KeyMode;
    //二维键行键值列表
    public ArrayList<DicDataItem> Dim2KeyItems = new ArrayList<>();
    //ID
    @PrimaryKey
    private int ID;
    //模板名称
    private String Name = "";
    //模板类别
    private int Classify;
    private String Code;
    private String ClassifyName = "";
    //有效标志
    private String EnabledFlag = "";
    //备注
    private String Remark = "";
    private ArrayList<InspectTemplate_Item> Items = new ArrayList<>();

    @Ignore
    private boolean curHistory = false;

    private int FillType;

    public boolean isCurHistory() {
        return curHistory;
    }

    public void setCurHistory(boolean curHistory) {
        this.curHistory = curHistory;
    }


    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public int getClassify() {
        return Classify;
    }

    public void setClassify(int classify) {
        Classify = classify;
    }

    public String getClassifyName() {
        return ClassifyName;
    }

    public void setClassifyName(String classifyName) {
        ClassifyName = classifyName;
    }

    public String getEnabledFlag() {
        return EnabledFlag;
    }

    public void setEnabledFlag(String enabledFlag) {
        EnabledFlag = enabledFlag;
    }

    public String getRemark() {
        return Remark;
    }

    public void setRemark(String remark) {
        Remark = remark;
    }

    public String getCode() {
        return Code;
    }

    public void setCode(String code) {
        Code = code;
    }

    public int getDim2KeyMode() {
        return Dim2KeyMode;
    }

    public void setDim2KeyMode(int dim2KeyMode) {
        Dim2KeyMode = dim2KeyMode;
    }

    public ArrayList<DicDataItem> getDim2KeyItems() {
        return Dim2KeyItems;
    }

    public void setDim2KeyItems(ArrayList<DicDataItem> dim2KeyItems) {
        Dim2KeyItems = dim2KeyItems;
    }

    public ArrayList<InspectTemplate_Item> getItems() {
        return Items;
    }

    public void setItems(ArrayList<InspectTemplate_Item> items) {
        Items = items;
    }

    public String isFillComplete() {
        for (InspectTemplate_Item item : Items) {
            if (item.getIsMustFill() == 1 && (TextUtils.isEmpty(item.getFillValue()) || TextUtils.isEmpty(item.getFillName()) ||
                    (item.getFillValue().equals(item.getItem().getNeedExtRemark()) && TextUtils.isEmpty(item.getRemark())))) {
                return item.getItem().getName();
            }
        }
        return null;
    }

    public int completeCount() {
        int count = 0;
        for (InspectTemplate_Item item : Items) {
            if (!TextUtils.isEmpty(item.getFillValue())  ) {
                ++count;
            }
        }
        return count;
    }

    public int getFillType() {
        return FillType;
    }

    public void setFillType(int fillType) {
        FillType = fillType;
    }
}
